//
//  GiftContentCollectionViewCell.m
//  礼物说
//
//  Created by dllo on 16/4/26.
//  Copyright © 2016年 sunzhichao. All rights reserved.
//

#import "GiftContentCollectionViewCell.h"

@interface GiftContentCollectionViewCell ()

@property (nonatomic, retain)BaseLabel *title;
@property (nonatomic, retain)BaseLabel *price;
@property (nonatomic, retain)BaseLabel *content;

@end

@implementation GiftContentCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self createCell];
    }
    return self;
}
- (void)dealloc{
    
    [_model release];
    [_title release];
    [_content release];
    [_price release];
    [super dealloc];
}
- (void)setModel:(GiftContentModel *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    _title.text = _model.name;
    _content.text = _model.content;
    _content.numberOfLines = 0;
    [_content sizeToFit];
    _price.text = _model.price;
}
- (void)createCell{
    
    self.title = [[BaseLabel alloc] init];
    [self.contentView addSubview:_title];
    [_title release];
    
    self.content = [[BaseLabel alloc] init];
    [self.contentView addSubview:_content];
    [_content release];
    
    self.price = [[BaseLabel alloc] init];
    [self.contentView addSubview:_price];
    [_price release];
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    [super layoutSubviews];
    _title.frame = CGRectMake(kWIDTHS(10), kWIDTHS(10), kWIDTHCELL - kWIDTHS(20), kWIDTHS(20));
    _price.frame = CGRectMake(kWIDTHS(10), kWIDTHS(35), kWIDTHS(100), kWIDTHS(20));
    _price.textColor = [UIColor redColor];
    _content.frame = CGRectMake(kWIDTHS(10), self.price.frame.origin.y + self.price.frame.size.height + kWIDTHS(5), kWIDTHCELL - kWIDTHS(20), kWIDTHS(60));
    _content.textColor = [UIColor grayColor];
}


@end
